//
//  AlertVIew.m
//  Estate
//
//  Created by heyong on 16/6/23.
//  Copyright © 2016年 ttsx. All rights reserved.
//
#define TOPVIEW_HEIGHT 45
#define TEXT_HEIGHT 150
#define PADDING 5
#import "AlertVIew.h"

@implementation AlertVIew
- (UITextView *)text{
    if(_text==nil){
        _text=[[UITextView alloc]initWithFrame:CGRectMake(0, TOPVIEW_HEIGHT, DEF_WIDTH(self), DEF_HEIGHT(self)-100)];
        _text.delegate=self;
    }
    return _text;
}

- (UIButton *)submit{
    if(_submit==nil){
        _submit=[[UIButton alloc]initWithFrame:CGRectMake(DEF_WIDTH(self)-90, DEF_HEIGHT(self)-45, 80, 35)];
        _submit.backgroundColor=[UIColor colorWithRed:0.60 green:0.75 blue:0.20 alpha:1.00];
        _submit.titleLabel.font=[UIFont systemFontOfSize:15.];
        [_submit setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_submit setTitle:@"提交" forState:UIControlStateNormal];
    }
    return _submit;
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor=[UIColor whiteColor];
        [self cteateView];
    }
    return self;
}

- (void)cteateView{
    UIView *topView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, DEF_WIDTH(self), TOPVIEW_HEIGHT)];
    topView.backgroundColor=[UIColor colorWithRed:0.08 green:0.58 blue:0.53 alpha:1.00];
    [self addSubview:topView];
    
    UIImageView *img=[[UIImageView alloc]init];
    img.image=[UIImage imageNamed:@"yijian"];
    [topView addSubview:img];
    [img mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(10);
        make.centerY.mas_equalTo(topView.mas_centerY);
        make.width.mas_offset(18);
        make.height.mas_offset(18);
    }];
    
    _title=[[UILabel alloc]init];
    [topView addSubview:_title];
    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(img.mas_right).mas_offset(5);
        make.centerY.mas_equalTo(topView.mas_centerY);
        
    }];
    _title.text=@"审阅意见";
    _title.textColor=[UIColor whiteColor];
    _title.font=[UIFont systemFontOfSize:13.];
    
    //关闭按钮
    _closeBtn =[[UIButton alloc]init];
    [_closeBtn setImage:[UIImage imageNamed:@"guanbi"] forState:UIControlStateNormal];
    [topView addSubview:_closeBtn];
    [_closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-18);
        make.centerY.mas_equalTo(topView.mas_centerY);
        make.width.mas_offset(18);
        make.height.mas_offset(18);
    }];
    
    //分割线
    UIView *line=[[UIView alloc]initWithFrame:CGRectMake(0, DEF_HEIGHT(self)-52, DEF_WIDTH(self), 1)];
    line.backgroundColor=[UIColor colorWithRed:0.87 green:0.87 blue:0.87 alpha:1.00];
    [self addSubview:line];
    
    [self addSubview:self.text];
    [self addSubview:self.submit];
    
}

- (void)textViewDidChange:(UITextView *)textView{
    if(self.textViewBlock){
        self.textViewBlock(textView.text);
    }
}
@end
